import socket

# 服务器地址和端口号
server_address = ('localhost', 1234)

# 创建TCP socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 连接服务器
client_socket.connect(server_address)

# 发送数据
message = "Hello, server!"
client_socket.send(message.encode())

# 接收服务器回复
data = client_socket.recv(1024)
print("Server replied:", data.decode())

# 关闭socket连接
client_socket.close()
